package com.ht.dao;

import com.ht.bean.HolidayStudent;
import com.ht.bean.Student;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface StuhdayCountDao {

    @Select({"<script>",
            "select s.stuName,count(h.stuId) as count from student s " +
            "right join holidaystudent h on s.stuId=h.stuId group by h.stuId" +
            "<if test=\"stuName!=null and stuName!=''\">",
            "having  s.stuName = #{stuName}" ,
            "</if>" ,
            "limit #{startIndex},#{pageSize}" +
            "</script>"})
    List<Map> countStuHlday(@Param("stuName") String stuName,@Param("startIndex") Integer startIndex, @Param("pageSize") Integer pageSize);

    @Select({"<script>",
            "select count(*) from(select s.stuName,count(h.stuId) as count from student s " +
            "right join holidaystudent h on s.stuId=h.stuId group by h.stuId) as wahh" +
            "<if test=\"stuName!=null and stuName!=''\">",
            "having  s.stuName = #{stuName}" ,
            "</if>" ,
            "</script>"})
    int limitStuHlday(@Param("stuName") String stuName);


    @Select("select s.stuName as stuName,count(h.stuId) as stuId from student s right join holidaystudent h on s.stuId=h.stuId group by h.stuId")
    List<Student> countMapName();

    @Select("select count(h.stuId) as countNum from student s right join holidaystudent h on s.stuId=h.stuId group by h.stuId")
    List<HolidayStudent> countMapNum();

}
